Clarify tag-only YamlDerivedType does not set default derived type#134
Merged
Merged
Conversation
Update doc comments on YamlDerivedType(Type) and YamlDerivedTypeAttribute(Type) constructors to clearly document that a tag-only entry (Discriminator=null, Tag!=null) does NOT become the default derived type. The default is only set when both Discriminator and Tag are null. Add 10 comprehensive tests covering: - Attribute-based tag-only entries: untagged values deserialize as base type - Runtime tag-only entries: untagged values deserialize as base type - Dictionary with mixed tagged/untagged values - Explicit default with tag-only entries coexisting - Roundtrip serialization for both attribute and runtime paths
Contributor
Author
|
P.S.: This is a clarification-only issue. Feel free to request any changes (i.e. "keep only the docs", "modify the test suite"), or even disregard it entirely 😉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When using
YamlDerivedType(Type)orYamlDerivedTypeAttribute(Type)with only aTag(no discriminator), the constructor doc comment stated the entry would be "the default when no discriminator matches." This was misleading — the actual behavior correctly treats tag-only entries as tag dispatch participants only, not as the default derived type.Scenario
With this configuration, an untagged YAML mapping should deserialize as the base type
PullMonitorConfiguration, not asCheckInMonitorConfiguration.Changes
Clarified doc comments on both
YamlDerivedType(Type)andYamlDerivedTypeAttribute(Type)constructors to explicitly document that:DiscriminatorandTagarenullTagis set, the entry participates in tag-based dispatch onlyAdded 10 comprehensive tests covering:
DerivedTypeMappings): untagged values deserialize as base type